#ifndef SDSHIP_H
#define SDSHIP_H

#include <set>
#include <math.h>
#include "../src/chipmunk.h"
#include "sdObject.h"
#include "sdTimed.h"

class sdShip : public sdObject {
private:
    cpFloat hp_;
	cpFloat hpMax_;
    
    //TODO: SHIP VARIABLES, ENCAPSULATE IN A SHIP CLASS, WITH HP, OBJECT, UPDATE, DRAW, ETC
	//Armor; Armor object
	//Thrusters; Forwards engines
	//Boosters; Quick bursts of thrust in a direction, some ships have more booster slots
	//Harpoints; Slots for offense / defense / utility
	//Reactor; Multiplier for Thrusters and Boosters, while moving pumps extra energy into...
	//Generator; Controls energy regeneration and capacity for shields / lasers / etc
	
	//TODO: THRUSTER/BOOSTER VARIABLES, LIKE ABOVE
	cpFloat deltaW_; //Turning speed, actually a factor(see implementation)
	cpFloat forwardsForce_; //How strong the thrusters are in a given direction
	cpFloat reverseForce_;
	cpFloat leftForce_;
	cpFloat rightForce_;

public:
    inline sdShip(int hp, int hpMax) : sdObject(cpBodyNew(0, 0)), hp_(hp), hpMax_(hpMax) {}
   
    void draw();
    //virtual void collide;
    
    //TODO: SHIP METHODS, SEE ABOVE
    void move(const cpVect& direction); //direction of force, amp 1.0 is full in that direction
    void turn(const cpVect& direction); //turn to face this direction at speed
    bool shoot(const int weapon, sdTimed& bullet);
    
    inline void takeDamage(cpFloat damage) {hp_ -= damage;}
    inline cpFloat getHp() {return hp_;}
	inline cpFloat getMaxHp() {return hpMax_;}
    inline bool dead() {return hp_ <= 0;}
    
    void getChunks(std::set<sdTimed*>* chunks);
    
    //TODO: THRUSTER/BOOSTER OBJECT METHODS, INSIDE SHIP
    inline void setDeltaW(cpFloat deltaW) {deltaW_ = deltaW;}
    inline cpFloat getDeltaW() {return deltaW_;}
    
 	inline void setForwardsForce(cpFloat forwardsForce) {forwardsForce_ = forwardsForce;}
	inline cpFloat getForwardsForce() {return forwardsForce_;}
	
	inline void setReverseForce(cpFloat reverseForce) {reverseForce_ = reverseForce;}
	inline cpFloat getReverseForce() {return reverseForce_;}
	
	inline void setLeftForce(cpFloat leftForce) {leftForce_ = leftForce;}
	inline cpFloat getLeftForce() {return leftForce_;}
	
	inline void setRightForce(cpFloat rightForce) {rightForce_ = rightForce;}
	inline cpFloat getRightForce() {return rightForce_;}
};

#endif
